package com.craney.testTextField
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	
	public class TextSelect
	{
		private var tf:TextField = new TextField();
		public function TextSelect(ps:Sprite)
		{
			var str:String = "0123456789";
			tf.border = true;
			tf.background = true;
			tf.autoSize = TextFieldAutoSize.LEFT;
			tf.text = str;
//			tf.setSelection(3, 9);
			tf.addEventListener(Event.ACTIVATE, active);
			tf.addEventListener(Event.ADDED, added);
			tf.addEventListener(Event.ADDED_TO_STAGE, addstage);
			tf.addEventListener(Event.RENDER, render);
//			tf.addEventListener(MouseEvent.CLICK, click);
//			tf.addEventListener(MouseEvent.MOUSE_UP, up);
			ps.addChild(tf);		
		}
		
		private function up(event:Event):void
		{
			trace("begin:", tf.selectionBeginIndex);
			trace("end:", tf.selectionEndIndex);
		}
		
		private function click(event:Event):void
		{
			var tf:TextField = event.target as TextField;
			
			tf.setSelection(3, 9);
			
		}
		
		private function active(event:Event):void
		{
			trace("active");

		}
		private function added(event:Event):void
		{
			var tf:TextField = event.target as TextField;
			tf.setSelection(3, 8);
			trace("added");
		}
		private function addstage(event:Event):void
		{
			var tf:TextField = event.target as TextField;
			tf.setSelection(3, 8);

			trace("addstage");
			
		}
		private function render(event:Event):void
		{
			trace("render");
			
		}
		
	}
}